package com.frank.loadinglibrary.special.cool.ball;

import ohos.agp.render.Canvas;

public class CoolBall {

    //绘制的中心坐标
    protected float mCurX;
    protected float mCurY;
    //暂定所有球的最大半径
    protected static final int MAX_RADIUS_CIRCLE = 60;

    //保存原始X位置
    protected float mPerX = mCurX;
    //是否结束
    protected boolean mIsEnd = false;
    //是否已经启动结束动画
    protected boolean mIsEndAnimStart = true;
    //结束时小球移动距离
    protected int mEndMovingLength;
    //结束动画时间长度
    protected int mDuration = 4000;
    float hsX, hsY;
    protected AnimatorStateListen mAnimatorStateListen;

    public CoolBall(float x, float y) {
        this.mCurX = x;
        this.mCurY = y;
        this.mPerX = x;
        hsX = getCurX();
        hsY = getCurY();
    }

    protected void initConfig() {
        //do nothing
    }

    protected void initAnim() {
        //do nothing
    }

    public CoolBall prepareAnim() {
        initConfig();
        initAnim();
        initEndAnim();
        return this;
    }

    public void startAnim() {
        //do nothing
    }


    protected void initEndAnim() {
        //do nothing
    }
    public void endAnim() {
        mIsEnd = true;
        mIsEndAnimStart = false;
    }

    ;

    public void reset() {
        mIsEnd = false;
        mIsEndAnimStart = true;
        mCurX = hsX;
        mCurY = hsY;
    }

    public void drawSelf(Canvas canvas) {
        //do nothing
    }

    public float getCurX() {
        return mCurX;
    }

    public float getCurY() {
        return mCurY;
    }

    public void setAnimatorStateListen(AnimatorStateListen animatorStateListen) {
        this.mAnimatorStateListen = animatorStateListen;
    }

    public interface AnimatorStateListen {
        /**
         * 单个动画结束
         */
        void onAnimatorEnd();

        /**
         * 移动动画结束
         */
        void onMoveEnd();

        /**
         * 所有动画结束
         */
        void onAllAnimatorEnd();
    }
}
